<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {
    public function __construct($application) {
        parent::__construct($application); 
        // make the config available to everyone
        Zend_Registry::set('config', new Zend_Config($this->getOptions()));      
    }

    public function run() {
        $this->view->addHelperPath(APPLICATION_PATH . '/views/helpers');
        $this->view->addHelperPath('App/View/Helper', 'App_View_Helper');
        $this->view->addHelperPath('App/View/Helper/Navigation', 'App_View_Helper_Navigation');
        Zend_Session::start();
        parent::run();
    }

    protected function _initAutoload() {
        $loader = new Zend_Application_Module_Autoloader(array(
            'namespace' => '',
            'basePath'  => APPLICATION_PATH)
        );
                
        return $loader;
    }
   
    protected function _initSession()
	{
		$config = Zend_Registry::get('config');
		$default = $config->default->session->name;

		$session = new Zend_Session_Namespace($default, true);
		$session->{'bill'}="This is to test for William";
		Zend_Registry::set('session', $session);
		$session->{'zheng'}="JianWen Zheng";
		//print_r($session->bill);
		//exit;

		return $session;
	}

	public function _initLocale()
	{
		$locale  = new Zend_Locale('en_US');
		 
		Zend_Registry::set('Zend_Locale', $locale);

		$region = $locale->getRegion();
		$lang = $locale->getLanguage();

		$translationFile = APPLICATION_PATH . "/languages/$lang.php";
		$translate = new Zend_Translate('array', $translationFile, $lang);
		Zend_Registry::set('Zend_Translate', $translate);
	}
/*
	protected function _initView()
	{
		$view = new Zend_View();
		$view->doctype('XHTML1_STRICT');

		$view->addHelperPath(APPLICATION_PATH . '/views/helpers');

		$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
		$viewRenderer->setView($view);

		$acl = App_AccessList::getAcl();

		$session = $this->getResource('session');
		$storage = new App_Auth_Storage_Session($session);
		if (!$storage->isEmpty()){
			$view->username = $storage->getUserName();
			$view->userrole = $storage->getUserRole();
		}

		return $view;
	}
	*/
  /*  
     protected function _initNavigation() {
      $pages = array(
        array(
            'controller'=>'index',
            'action'=>'index',
            'label'=>'Home'
        ),
        array(
            'controller'=>'index',
            'action'=>'coupon',
            'label'=>'Coupons'
        ),
        array(
            'controller'=>'store',
            'action'=>'index',
            'label'=>'Stores'
        ),
       
        array(
            'controller'=>'index',
            'action'=>'aboutus',
            'label'=>'About Us'
        )
      );
      $resource = new Zend_Application_Resource_Navigation(array(
        'pages' => $pages,
      ));
      $resource->setBootstrap($this);
      return $resource->init();
    }
	*/
}


